<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script src="./vue.global.js"></script>
  <title>Document</title>
</head>
<body>
  <div id="root">
    
  </div>
  <script>
    const { createApp, computed, provide, ref, inject, onMounted } = window.Vue

    const objs = {}

    const track = (obj, key) => {
      objs[key] = obj[key]
    }

    const trigger = (obj, key, value) => {
      objs[key] = value
    }

    const app = createApp({
      setup(props) {
        const count = {
          value: 100,
          x: 200,
          list: ['a', 'b']
        }

        const handler = {
          get(obj, key) {
            track(obj, key)
            Reflect.get(...arguments)
            return obj[key]
          },
          set(obj, key, value) {
            trigger(obj, key, value)
            Reflect.set(...arguments)
          }
        }

        const proxy = new Proxy(count, handler)

        proxy.value
        proxy.x
        proxy.list

        console.log(objs)

        // proxy.value = 1000
        proxy.list[0] = 'aaa'
        console.log(objs)
      }
    })

    let vm = app.mount('#root')
  </script>
</body>
</html>